;; generic/comparison.scm - (c) rohan drape, 2003-2005

;; Comparison methods.  The names are the numerical forms with an
;; appended question mark.

(define-generic <?)
(define-method (<? (a <number>) (b <number>)) (< a b))
(define-method (<? (a <string>) (b <string>)) (string<? a b))
(define-method (<? (a <symbol>) (b <symbol>)) (symbol<? a b))
(define-method (<? (a <char>)   (b <char>))   (char<? a b))

(define-generic >?)
(define-method (>? (a <number>) (b <number>)) (> a b))
(define-method (>? (a <string>) (b <string>)) (string>? a b))
(define-method (>? (a <symbol>) (b <symbol>)) (symbol>? a b))
(define-method (>? (a <char>)   (b <char>))   (char>? a b))

(define-generic =?)
(define-method (=? (a <number>) (b <number>)) (= a b))
(define-method (=? (a <string>) (b <string>)) (string=? a b))
(define-method (=? (a <symbol>) (b <symbol>)) (symbol=? a b))
(define-method (=? (a <char>)   (b <char>))   (char=? a b))

(define-generic <=?)
(define-method (<=? (a <number>) (b <number>)) (<= a b))
(define-method (<=? (a <string>) (b <string>)) (string<=? a b))
(define-method (<=? (a <symbol>) (b <symbol>)) (symbol<=? a b))
(define-method (<=? (a <char>)   (b <char>))   (char<=? a b))

(define-generic >=?)
(define-method (>=? (a <number>) (b <number>)) (>= a b))
(define-method (>=? (a <string>) (b <string>)) (string>=? a b))
(define-method (>=? (a <symbol>) (b <symbol>)) (symbol>=? a b))
(define-method (>=? (a <char>)   (b <char>))   (char>=? a b))

;; Three State Comparison.

(define-generic tsc)
(define-method (tsc (a <number>) (b <number>)) (number-tsc a b))
(define-method (tsc (a <string>) (b <string>)) (string-tsc a b))
(define-method (tsc (a <symbol>) (b <symbol>)) (symbol-tsc a b))
(define-method (tsc (a <char>)   (b <char>))   (char-tsc a b))
